﻿<%@ Page Title="Strategic Asset Management Las Vegas: Rental" Language="C#"
   MasterPageFile="~/Site2.Master" AutoEventWireup="true" CodeBehind="RentProjection.aspx.cs"
   Inherits="LenderClearingHouse.RentProjection" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Src="ListFilterControl.ascx" TagName="ListFilterControl" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphPageHeader" runat="server">
   Rental
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cphMain" runat="server">
   <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
      <AjaxSettings>
         <telerik:AjaxSetting AjaxControlID="grid">
            <UpdatedControls>
               <telerik:AjaxUpdatedControl ControlID="grid" UpdatePanelHeight="" />
            </UpdatedControls>
         </telerik:AjaxSetting>
      </AjaxSettings>
   </telerik:RadAjaxManager>
   <asp:SqlDataSource ID="SqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SQLConnection %>"
      OnSelecting="SqlDataSource_Selecting" SelectCommand="getRentProjection" CancelSelectOnNullParameter="false"
      SelectCommandType="StoredProcedure">
      <SelectParameters>
         <asp:Parameter ConvertEmptyStringToNull="False" Name="Apn" Type="String" />
         <asp:Parameter ConvertEmptyStringToNull="False" Name="PropLocation" Type="String" />
         <asp:Parameter ConvertEmptyStringToNull="False" Name="Zip" Type="String" />
         <asp:Parameter ConvertEmptyStringToNull="False" Name="UserId" Type="Int32" />
      </SelectParameters>
   </asp:SqlDataSource>
   <table style="with: 100%">
      <tr>
         <td>
            <fieldset style="height: 50px; float: left;">
               <legend>Add</legend>
               <asp:TextBox ID="tbApnAdd" runat="server" ValidationGroup="apnadd" style="width:110px;"></asp:TextBox>&nbsp;&nbsp;
               <asp:Button ID="btnApnAdd" runat="server" Text="Add by APN" OnClick="btnApnAdd_Click" ValidationGroup="apnadd" />
               <asp:RequiredFieldValidator ID="reqApnAdd" runat="server" ErrorMessage="Apn can't be empty!"
                  ControlToValidate="tbApnAdd" SetFocusOnError="True" Display="Dynamic" ValidationGroup="apnadd"></asp:RequiredFieldValidator>
               <br />
            </fieldset>
            <fieldset style="height: 50px; float: left;" id="filterGroup" runat="server">
               <legend>Filter</legend>&nbsp;&nbsp;Investor:&nbsp;
               <telerik:RadComboBox ID="cbInvestor" runat="server" Width="200" EmptyMessage="Type a Investor Name"
                  AllowCustomText="true" MarkFirstMatch="true" AutoPostBack="true" DataSourceID="SqlDataSourceInvestorCombo"
                  DataTextField="UserName" DataValueField="UserId" OnSelectedIndexChanged="cbInvestor_SelectedIndexChanged">
               </telerik:RadComboBox>
               <asp:SqlDataSource ID="SqlDataSourceInvestorCombo" runat="server" ConnectionString="<%$ ConnectionStrings:SQLConnection %>"
                  SelectCommand="getInvestorsCombo" SelectCommandType="StoredProcedure" />
            </fieldset>
            <fieldset style="height: 85px; float: left;" id="paramsGroup" runat="server">
               <legend>Parameters</legend>
                    &nbsp;&nbsp;<span style="font-size:12px;">CC Front,&nbsp;%:&nbsp;</span>
                    <asp:TextBox ID="tbF2" runat="server" ValidationGroup="percents" Width="30"/>
                    &nbsp;&nbsp;<span style="font-size:12px;">Tax,&nbsp;%:&nbsp;</span>
                    <asp:TextBox ID="tbK2" runat="server" ValidationGroup="percents" Width="30"/>
                    &nbsp;&nbsp;<span style="font-size:12px;">Vacancy Loss,&nbsp;%:&nbsp;</span>
                    <asp:TextBox ID="tbL2" runat="server" ValidationGroup="percents" Width="30"/>&nbsp;&nbsp;
               <br />
               &nbsp;&nbsp;<span style="font-size:12px;">Maintenance,&nbsp;%:&nbsp;</span>
                    <asp:TextBox ID="tbM2" runat="server" ValidationGroup="percents" Width="30"/>
                    &nbsp;&nbsp; <span style="font-size:12px;">Management,&nbsp;%:&nbsp;</span>
                    <asp:TextBox ID="tbN2" runat="server" ValidationGroup="percents" Width="30"/>
                    &nbsp;&nbsp; <span style="font-size:12px;">Insurance,&nbsp;%:&nbsp;</span>
                    <asp:TextBox ID="tbP2" runat="server" ValidationGroup="percents" Width="30"/>&nbsp;&nbsp;

               <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" ValidationGroup="percents" />
               <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Invalid values"
                  ControlToValidate="tbF2" MinimumValue="0" MaximumValue="100" ValidationGroup="percents"
                  SetFocusOnError="True" Type="Currency" Display="Dynamic"></asp:RangeValidator>
               <asp:RangeValidator ID="RangeValidator2" runat="server" ErrorMessage="Invalid values"
                  ControlToValidate="tbK2" MinimumValue="0" MaximumValue="100" ValidationGroup="percents"
                  SetFocusOnError="True" Type="Currency" Display="Dynamic"></asp:RangeValidator>
               <asp:RangeValidator ID="RangeValidator3" runat="server" ErrorMessage="Invalid values"
                  ControlToValidate="tbL2" MinimumValue="0" MaximumValue="100" ValidationGroup="percents"
                  SetFocusOnError="True" Type="Currency" Display="Dynamic"></asp:RangeValidator>
               <asp:RangeValidator ID="RangeValidator4" runat="server" ErrorMessage="Invalid values"
                  ControlToValidate="tbM2" MinimumValue="0" MaximumValue="100" ValidationGroup="percents"
                  SetFocusOnError="True" Type="Currency" Display="Dynamic"></asp:RangeValidator>
               <asp:RangeValidator ID="RangeValidator5" runat="server" ErrorMessage="Invalid values"
                  ControlToValidate="tbN2" MinimumValue="0" MaximumValue="100" ValidationGroup="percents"
                  SetFocusOnError="True" Type="Currency" Display="Dynamic"></asp:RangeValidator>
               <asp:RangeValidator ID="RangeValidator6" runat="server" ErrorMessage="Invalid values"
                  ControlToValidate="tbP2" MinimumValue="0" MaximumValue="100" ValidationGroup="percents"
                  SetFocusOnError="True" Type="Currency" Display="Dynamic"></asp:RangeValidator>
               <br />
            </fieldset>
         </td>
      </tr>
   </table>
   <br />
   <uc1:ListFilterControl ID="listFilter" runat="server" />
   <!--Panel Five: "Export & etc..."-->
   <div class="panel5">
      <table width="940" border="0" cellspacing="0" cellpadding="0">
         <tr>
            <td width="122" height="32" valign="middle">
               &nbsp;
            </td>
            <td width="40" valign="middle">
               <img src="images/excel_icon.png" width="30" height="30" />
            </td>
            <td width="137" valign="middle">
               <asp:LinkButton ID="lnkExportToExcel" CssClass="link1" runat="server" Text="Export To Excel"
                  OnClick="lnkExportToExcel_Click"></asp:LinkButton>
            </td>
            <td width="40" valign="middle">
               <img src="images/refresh_icon.png" width="30" height="30" />
            </td>
            <td width="118" valign="middle">
               <asp:LinkButton ID="lnkRefreshGrid" CssClass="link1" runat="server" OnClick="lnkRefreshGrid_Click"
                  Text="Refresh Grid"></asp:LinkButton>&nbsp;
            </td>
            <td width="40" valign="middle">
            </td>
            <td width="150" valign="middle" id="td1" runat="server">
            </td>
            <td width="*">
               &nbsp;
            </td>
         </tr>
      </table>
   </div>
   <br />
   <div class="panel7">
      <telerik:RadGrid ID="grid" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource"
         Width="1160px" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True"
         PageSize="10" ShowFooter="True" ShowStatusBar="True" 
          OnItemDataBound="grid_ItemDataBound" OnItemCreated="grid_ItemCreated"
          OnInsertCommand="grid_InsertCommand" OnUpdateCommand="grid_UpdateCommand" OnDeleteCommand="grid_DeleteCommand"
          OnPageIndexChanged="grid_PageIndexChanged" OnSortCommand="grid_SortCommand" OnItemCommand="grid_ItemCommand">
         <GroupingSettings CaseSensitive="False" />
         <ClientSettings>
            <Scrolling ScrollHeight="500px" AllowScroll="True" UseStaticHeaders="True" FrozenColumnsCount="2" />
         </ClientSettings>
         <MasterTableView DataSourceID="SqlDataSource" Width="100%" DataKeyNames="Apn,RentProjectionUnitId">
            <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
            <Columns>
               <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmText="Delete this Rent Projection item?" ConfirmTitle="Delete" UniqueName="column"/>
               <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="NewUnit" UniqueName="btnNewUnit" ImageUrl="~/images/plus.png" Text="Add Unit"/>
               <telerik:GridEditCommandColumn ButtonType="ImageButton"/>
               
               <telerik:GridHyperLinkColumn 
                        DataTextField="Apn" HeaderText="Apn" 
                        UniqueName = "Apn" SortExpression = "Apn"
                        DataNavigateUrlFormatString="~/RentProjectionUnit.aspx?apn={0}"
                        DataNavigateUrlFields="Apn">
               </telerik:GridHyperLinkColumn>
               <telerik:GridBoundColumn DataField="InvestorName" HeaderText="Owner" SortExpression="InvestorName"
                  UniqueName="InvestorName">
               </telerik:GridBoundColumn>
               <telerik:GridHyperLinkColumn 
                        DataTextField="PropertyLocation" HeaderText="Property" 
                        UniqueName = "PropertyLocation" SortExpression = "PropertyLocation"
                        DataNavigateUrlFormatString="~/PropertyDetails2.aspx?propertyId={0}"
                        DataNavigateUrlFields="PropertyId">
               </telerik:GridHyperLinkColumn>
               <telerik:GridBoundColumn DataField="ZipCode" HeaderText="Zip" SortExpression="ZipCode"
                  UniqueName="ZipCode">
               </telerik:GridBoundColumn>

               <telerik:GridBoundColumn DataField="UnitNumber" HeaderText="Unit #" SortExpression="UnitNumber" UniqueName="UnitNumber"/>
               <telerik:GridBoundColumn DataField="SquareFootage" HeaderText="Square Footage" SortExpression="SquareFootage" UniqueName="SquareFootage"/>
               <telerik:GridBoundColumn DataField="Bedrooms" HeaderText="Bedrooms" SortExpression="Bedrooms" UniqueName="Bedrooms"/>
               <telerik:GridBoundColumn DataField="Bathrooms" HeaderText="Bathrooms" SortExpression="Bathrooms" UniqueName="Bathrooms"/>
               <telerik:GridBoundColumn DataField="Rehab" DataType="System.Decimal" HeaderText="Rehab" SortExpression="Rehab" UniqueName="Rehab" DataFormatString="{0:c}"/>
               <telerik:GridBoundColumn DataField="RentProjectionUnitId" HeaderText="" SortExpression="RentProjectionUnitId" UniqueName="RentProjectionUnitId" Visible="false"/>

               <telerik:GridBoundColumn DataField="PurchasePrice" DataType="System.Decimal" HeaderText="Purchase Price"
                  SortExpression="PurchasePrice" UniqueName="PurchasePrice" DataFormatString="{0:c}">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="ClosingCost" DataType="System.Decimal" HeaderText="Closing Cost"
                  SortExpression="ClosingCost" UniqueName="ClosingCost" DataFormatString="{0:c}">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="PurchaseTotal" DataType="System.Decimal" HeaderText="Purchase Total"
                  SortExpression="PurchaseTotal" UniqueName="PurchaseTotal" DataFormatString="{0:c}">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="TotalAcquisition" DataType="System.Decimal" HeaderText="Total Acquisition"
                  SortExpression="TotalAcquisition" UniqueName="TotalAcquisition" DataFormatString="{0:c}">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="RentMonth" DataType="System.Decimal" HeaderText="Rent/month"
                  SortExpression="RentMonth" UniqueName="RentMonth" DataFormatString="{0:c}">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="TaxesMonth" DataType="System.Decimal" HeaderText="Taxes/month"
                  SortExpression="TaxesMonth" UniqueName="TaxesMonth" DataFormatString="{0:c}">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="AnnualVacancyLossMonth" DataType="System.Decimal"
                  HeaderText="Annual Vacancy Loss/month" SortExpression="AnnualVacancyLossMonth"
                  UniqueName="AnnualVacancyLossMonth" DataFormatString="{0:c}">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="MaintenanceMonth" DataType="System.Decimal" HeaderText="Maintenance/month"
                  SortExpression="MaintenanceMonth" UniqueName="MaintenanceMonth" DataFormatString="{0:c}">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="ManagementMonth" DataType="System.Decimal" HeaderText="Management/month"
                  SortExpression="ManagementMonth" UniqueName="ManagementMonth" DataFormatString="{0:c}">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="HOAMonth" DataType="System.Decimal" HeaderText="HOA/month"
                  SortExpression="HOAMonth" UniqueName="HOAMonth" DataFormatString="{0:c}">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="InsuranceMonth" DataType="System.Decimal" HeaderText="Insurance/month"
                  SortExpression="InsuranceMonth" UniqueName="InsuranceMonth" DataFormatString="{0:c}">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="MonthlyExpense" DataType="System.Decimal" HeaderText="Monthly Expense"
                  SortExpression="MonthlyExpense" UniqueName="MonthlyExpense" DataFormatString="{0:c}">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="MonthlyCashFlowProfit" DataType="System.Decimal"
                  HeaderText="Monthly Cash Flow Profit" SortExpression="MonthlyCashFlowProfit" UniqueName="MonthlyCashFlowProfit"
                  DataFormatString="{0:c}">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="AnnualCashFlowProfit" DataType="System.Decimal"
                  HeaderText="Annual Cash Flow Profit" SortExpression="AnnualCashFlowProfit" UniqueName="AnnualCashFlowProfit"
                  DataFormatString="{0:c}">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="CashFlowProfitVsTotalAcquisition" DataType="System.Decimal"
                  HeaderText="Cash Flow Profit Vs. Total Acquisition" SortExpression="CashFlowProfitVsTotalAcquisition"
                  UniqueName="CashFlowProfitVsTotalAcquisition" DataFormatString="{0:F2}%">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="RenterName" HeaderText="Renter Name" SortExpression="RenterName"
                  UniqueName="RenterName">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="RenterPhone" HeaderText="Renter Phone" SortExpression="RenterPhone"
                  UniqueName="RenterPhone">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="DateRentedFrom" DataType="System.DateTime" HeaderText="Date Rented From"
                  SortExpression="DateRentedFrom" UniqueName="DateRentedFrom" DataFormatString="{0:MM/dd/yyyy}">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="DateRentedTo" DataType="System.DateTime" HeaderText="Date Rented To"
                  SortExpression="DateRentedTo" UniqueName="DateRentedTo" DataFormatString="{0:MM/dd/yyyy}">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="ManagementCompany" HeaderText="Property Management Company"
                  SortExpression="ManagementCompany" UniqueName="ManagementCompany">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="Contact" HeaderText="Contact" SortExpression="Contact"
                  UniqueName="Contact">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="CompanyPhone" HeaderText="Company Phone" SortExpression="CompanyPhone"
                  UniqueName="CompanyPhone">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="CompanyAddress" HeaderText="Company Address"
                  SortExpression="CompanyAddress" UniqueName="CompanyAddress">
               </telerik:GridBoundColumn>
               
            </Columns>
            <EditFormSettings EditFormType="WebUserControl" UserControlName="RentProjectionEditControl.ascx">
               <EditColumn UniqueName="EditCommandColumn1">
               </EditColumn>
            </EditFormSettings>
            <PagerStyle AlwaysVisible="True" />
         </MasterTableView>
         <PagerStyle AlwaysVisible="True" />
      </telerik:RadGrid>
   </div>
</asp:Content>
